//
//  TimeDreminderViewController.m
//  味·道
//
//  Created by lanou3g on 15/6/30.
//  Copyright (c) 2015年 WMR. All rights reserved.
//

#import "TimeDreminderViewController.h"
#import "TimeAddViewController.h"
#import "MaocHeader.h"
#import "AddPlainTableViewCell.h"

@interface TimeDreminderViewController ()
@property (nonatomic,retain)UITableView *tableView;
@property (nonatomic,retain)NSMutableArray *indexes;
@end

@implementation TimeDreminderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createCustomLab];
    [self createTableView];
    [self createAddTimer];
    [self createAddEdite];
    [self insertCellAtIndex];
    // Do any additional setup after loading the view.
}
- (void)createCustomLab{
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(150, 20, 100, 30)];
    [customLab setTextColor:[UIColor whiteColor]];
    [customLab setText:@"定时提醒"];
    customLab.font = [UIFont boldSystemFontOfSize:20];
    [self.view addSubview:customLab];
    [customLab release];
}
- (void)createTableView{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 55, SCREEN_WIDTH, SCREEN_HEIGHT-55)style:(UITableViewStylePlain)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
}
- (void)createAddTimer{
    UIButton *addTimePlain = [UIButton buttonWithType:(UIButtonTypeSystem)];
    addTimePlain.frame = CGRectMake(250, 20, 80, 20);
    [addTimePlain setTitle:@"添加定时" forState:(UIControlStateNormal)];
    [addTimePlain addTarget:self action:@selector(addTimePlain:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:addTimePlain];
}
- (void)addTimePlain:(UIButton *)button{
    TimeAddViewController *timeAdd = [[TimeAddViewController alloc] init];
    [self.rightVC.navigationController pushViewController:timeAdd animated:YES];
}
- (void)createAddEdite{
    UIButton *edite = [UIButton buttonWithType:(UIButtonTypeSystem)];
    edite.frame = CGRectMake(330, 20, 30, 20);
    [edite setTitle:@"编辑" forState:(UIControlStateNormal)];
    [edite addTarget:self action:@selector(editeHistory:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:edite];
}
- (void)editeHistory:(UIButton *)button{
    
}
- (NSArray *)insertCellAtIndex{
    if (self.num) {
        _indexes = [[NSMutableArray alloc] initWithCapacity:20];
        NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
        [_indexes addObject:index];
        [self.tableView beginUpdates];
        [self.tableView insertRowsAtIndexPaths:_indexes withRowAnimation:UITableViewRowAnimationLeft];
        [self.tableView endUpdates];
        return _indexes;
    }else{
        return nil;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#warning  tableVeiw
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.indexes.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.num) {
        static NSString *str = @"cell";
        AddPlainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
        if (cell == nil) {
            cell = [[AddPlainTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:str];
        }
        cell.label.text = self.str;
        return cell;
    }else{
        return nil;
    }
}
//- (BOOL)compareDateWithNow{
//    if (<#condition#>) {
//        return YES
//    }else{
//        return NO;
//    }
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
